
$(function() {
	$('.page-content').css('height',$(document).height()-103);
	window.onresize = function() {
		$('.page-content').css('height',$(document).height()-103);
	};
	//alert("进入");
	 sessionStorage.setItem("user_state",$("#userState").val());
	var userState=sessionStorage.getItem("user_state");
	if(userState==3){
	$.ajax({
		url : '/IT_TalentEvaluation/MenuController/menuTree.action',
		dataType : 'json',
		async : false,
		success : function(data) {
			var menulist = '';
			$.each(data, function(i, n) {
				if(n.id!=5){
					menulist += '<li class="menu-list"><a><i class="fa '+n.classes+' fa-2x"></i> <span>&nbsp;&nbsp;'+n.text+'</span></a><ul class="sub-menu-list">';
					$.each(n.nodes, function(j, o) {
						var url = o.url;
						var s = url.lastIndexOf("/");  
						var e = url.indexOf(".");
						menulist += '<li><a addtabs="'+url.substring(s+1,e)+'" url="'+url+'">&nbsp;&nbsp;&nbsp;'+o.text+'</a></li>';
					});
					menulist += '</ul></li>';
				}
			});
			menulist += '<script src="/IT_TalentEvaluation/script/scripts.js"></script>';
	       
			$('#nav').html(menulist);
		}
	});
	}
	else if(userState==4){
		$.ajax({
			url : '/IT_TalentEvaluation/MenuController/menuTree01.action',
			dataType : 'json',
			async : false,
			success : function(data) {
				var menulist = '';
				$.each(data, function(i, n) {
					if(n.id!=5){
						menulist += '<li class="menu-list"><a><i class="fa '+n.classes+' fa-2x"></i> <span>&nbsp;&nbsp;'+n.text+'</span></a><ul class="sub-menu-list">';
						$.each(n.nodes, function(j, o) {
							var url = o.url;
							var s = url.lastIndexOf("/");  
							var e = url.indexOf(".");
							menulist += '<li><a addtabs="'+url.substring(s+1,e)+'" url="'+url+'">&nbsp;&nbsp;&nbsp;'+o.text+'</a></li>';
						});
						menulist += '</ul></li>';
					}
				});
				menulist += '<script src="/IT_TalentEvaluation/script/scripts.js"></script>';
		
				$('#nav').html(menulist);
			}
		});
		}
	
});

function showWindow(){
	var docElm = document.documentElement;

	//W3C 

	if (docElm.requestFullscreen) { 

	docElm.requestFullscreen(); 

	}

	//FireFox 

	else if (docElm.mozRequestFullScreen) { 

	docElm.mozRequestFullScreen(); 

	}

	//Chrome等 

	else if (docElm.webkitRequestFullScreen) { 

	docElm.webkitRequestFullScreen(); 

	}

	//IE11

	else if (elem.msRequestFullscreen) {

	elem.msRequestFullscreen();

	}
	$("#hideWindow").css("display","block");
	$("#showWindow").css("display","none");
}
function hideWindow(){
	//W3C 
	if (document.exitFullscreen) { 
		document.exitFullscreen(); 
		} 
		else if (document.mozCancelFullScreen) { 
		document.mozCancelFullScreen(); 
		} 
		else if (document.webkitCancelFullScreen) { 
		document.webkitCancelFullScreen(); 
		} 
		else if (document.msExitFullscreen) { 
		document.msExitFullscreen(); 
		}
	$("#hideWindow").css("display","none");
	$("#showWindow").css("display","block");
}
function pswd(){
	$('#alterModal').modal('show');
}
function res(){
	$("#oldPassword").val("");
	$("#newPassword").val("");
	//alert("重置");
}
function sub(){
	var oldPassword=$("#oldPassword").val().trim();
	var newPassword=$("#newPassword").val().trim();
	
	if(oldPassword=="" || newPassword==""){
		toastr.warning("请输入密码!");
	}else if(vali(newPassword)!=0){
		toastr.warning(vali(newPassword));
	}else{
		$.ajax({
			type : "POST",
			url : "/PM/UserController//modifyPassword.action",
			data : {"extend":newPassword,"password":oldPassword},
			success : function(data) {
				var a=JSON.parse(data);
				if(a.error_code=="密码修改失败"){
					toastr.warning("旧密码错误");
				}else{
					$('#alterModal').modal('hide');
					toastr.success("修改成功");
					$("#oldPassword").val("");
			    	$("#newPassword").val("");
				}
			},
			error : function(request) {
				toastr.error("操作错误!");
			}
		});
		
	}
	
}
function vali(str){
	var flag=0;
	var strr;
	if (str.length<6 || str.length>18){
		flag++;
	}
	if (!/^[a-zA-Z]/.test(str)){
		flag++;
	}
	if (!/[0-9]/.test(str)){
		flag++;
	}
	if(!/[^A-Za-z0-9]/.test(str)){
		flag++;
	}
	if(flag!=0){
		strr="以字母开头，长度在6-12之间，必须包含数字和特殊字符。"
	}else{
		strr=0;
	}
	return strr;
};
function showLocale(objD)
{
  var str;
  var yy = objD.getYear();
   if(yy<1900) yy = yy+1900;
  var MM = objD.getMonth()+1;
   if(MM<10) MM = '0' + MM;
  var dd = objD.getDate();
   if(dd<10) dd = '0' + dd;
  var hh = objD.getHours();
   if(hh<10) hh = '0' + hh;
  var mm = objD.getMinutes();
   if(mm<10) mm = '0' + mm;
  var ss = objD.getSeconds();
   if(ss<10) ss = '0' + ss;
  var ww = objD.getDay();  
    str =yy + " 年 " + MM + " 月 " + dd + " 日 " + hh + " : " + mm + " : " + ss;
   //alert(str);
            return str;
}
function tick()
{
  var today;
  today = new Date();
  $("#newTime").html(showLocale(today));
  window.setTimeout("tick()", 1000);
}

var myChart = echarts.init(document.getElementById('pieEchart'),'macarons');
function showWorkset(){
	$.ajax({
		type : "POST",
		url : "/IT_TalentEvaluation/MenuController/workSet.action",
		data : {},
		success : function(data) {
		alert("111");
		},
		error : function(request) {
			toastr.error("操作错误!");
		}
	});
}
function refreshIndex(){
	getCharts();
	showWorkset();
}